import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Stack;
public class Chap3_1 {
    public  static  void conversion(int N,int r){
        SequenceStack<Integer> s = new SequenceStack<>();
        while (N!=0){
            s.push(N%r);
            N=N/2;
        }
        System.out.println("转化结果为：");
        while (!s.isEmpty()){
            System.out.print(s.pop()+"\t");
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br;
        Integer num,radix;
        br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("请输入一个十进制数：");
        num = Integer.parseInt(br.readLine());
        System.out.print("转化进制：");
        radix = Integer.parseInt(br.readLine());
        conversion(num,radix);
    }
}
